package com.wangsd.web.weixin.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.wangsd.web.weixin.entity.Follow;
import com.wangsd.web.weixin.mapper.FollowMapper;
import com.wangsd.web.weixin.service.FollowService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author generator
 * @since 2019-11-04
 */
@Service
public class FollowServiceImpl extends ServiceImpl<FollowMapper, Follow> implements FollowService {
    @Resource
    FollowMapper followMapper;

    @Override
    public void deleteByAppIdAndOpenId(String appId, String openid) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("app_id", appId);
        queryWrapper.eq("open_id", openid);
        followMapper.delete(queryWrapper);
    }

    @Override
    public Follow selectByUnionId(String unionId) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("union_id", unionId);
        return followMapper.selectOne(queryWrapper);
    }
}
